﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Create.aspx.cs" Inherits="SF.Dict.Web.Create" %>

<%@ Register Src="UserControls/ucHeader.ascx" TagName="ucHeader" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>新建词汇表 | 挚友云海</title>
	<meta http-equiv="X-UA-Compatible" content="IE=8" />
	<script type="text/javascript" src="/Common/jquery-1.3.2.js"></script>
	<link href="/Common/base.css" rel="stylesheet" type="text/css" />
	<link href="/Common/home.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" charset="utf-8">
		$(document).ready(
			function () {
				$.each($('.action'), function () {
					var txt = $(this).text();
					if (txt == '例子') {
						$(this).bind("click", function () {
							$('#tb_dicts').val('work,friends,go,home,picture,swron,dusk,parturition,grumpy,scent,heart,sum up,deflate,explicite');
						});
					}
					else if (txt == '创建') {
						$(this).bind("click", { fun: Create, check: Check, title: "确认屏蔽此评论？", argus: { again: false} }, ShowMiniHint);
					}
					else if (txt == '取消') {
						if ($(this).attr('id') == 'pb_cancel') {
							$(this).bind("click", function () {
								window.history.go(-1);
							});
						}
					}
				});
			});

		function Create(argus) {
			var again = argus.again;
			$.ajax({
				url: '/Submit/submit.ashx?page=voc&action=015&rnd=' + Math.random(),
				type: 'POST',
				timeout: 5000,
				dataType: "json",
				data: { 'name': $('#tb_title').val(), 'desc': $('#tb_instruction').val(), 'dicts': $('#tb_dicts').val(), 'sid': $("input[name='stations']:checked").val() },
				error: function () {
					if (again) {
						AddMiniHint('重试失败，请稍候再试');
						HideMiniPop(1500);
					}
					else {
						AddMiniHint('操作失败，<a class="action" onclick="Create({again:true})">请重试</a>');
					}
				},
				success: function (json) {
					if (json.code == 0) {
						AddMiniHint('操作成功！');

						HideMiniPop(1000);

						setTimeout(function () { window.location = "/voc.aspx?vid=" + json.msg; }, 1000);
					}
					else {
						if (again) {
							AddMiniHint('重试失败，请稍候再试');
							HideMiniPop(1500);
						}
						else {
							AddMiniHint('操作失败，<a class="action" onclick="Create({again:true})">请重试</a>');
						}
					}
				}
			});
		}

		function Check() {
			if ($('#tb_title').val().trim() == '' || $('#tb_dicts').val().trim() == '') {
				return '<strong>标题</strong> 和 <strong>单词列表</strong> 不能为空!';
			}
			else {
				return '';
			}
		}
	</script>

	<style type="text/css">
		#station li{
			float:left;
			color: #5B6772;
			font-size: 14px;
			font-weight: normal;
		}
		#station input{
			padding: 7px;
			height:30px;
			width: 20px;
		}
		#station label{
			height:30px;
			display:inline-block;
			padding-top:10px;
		}
		#station div{
			display:inline-block;
			float:left;
		}

	</style>
</head>
<body>
	<form id="form1" runat="server">
	<div id="wrap">
		<uc1:ucHeader ID="ucHeader1" PageName="publish" runat="server" />
		<div id="content-holder">
			<div id="content">
				<div id="main">
					<div id="publisher" class="publisher clearfix">
						<div id="pb_form">
							<h2>
								创建词汇表
							</h2>
							<h3>
								标题<span>(必填)</span>
							</h3>
							<asp:TextBox runat="server" ID="tb_title" TextMode="SingleLine"></asp:TextBox>
							<h3>适用<span>（选主要人群)</span></h3>
							<div class="clearfix">
								<asp:Literal ID="ltl_station" runat="server"></asp:Literal>
							</div>
							<h3>
								介绍</h3>
							<asp:TextBox runat="server" ID="tb_instruction" TextMode="MultiLine"></asp:TextBox>
							<h3>
								单词列表<span>(必填. 单词用，分割，只输入单词即可)<a class="action">例子</a></span></h3>
							<asp:TextBox runat="server" ID="tb_dicts" TextMode="MultiLine"></asp:TextBox>
							<div id="pb_button">
								<a id="pb_submit" class="blue-button action">创建</a> <a id="pb_cancel" class="gray-button action">
									取消</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div id="minipop-holder" class="hide">
			<div id="minipop-action" class="minipop">
				<div class="gray6">
					<div id="minipop-tip">
					</div>
				</div>
				<div class="btn-holder">
					<span><a id="minipop-submit" href="javascript:void(0)" class="action">确定</a></span>&nbsp;&nbsp;
					<span><a href="javascript:void(0)" onclick="HideMiniPop()" class="action">取消</a>
					</span>
				</div>
			</div>
			<div id="minipop-hint" class="minipop hide">
				<div class="gray6">
					<div id="minipop-hint-tip">
					</div>
				</div>
			</div>
		</div>
	</div>
	</form>
</body>
</html>
